package com.cmic.rcs.emoji.common.task;//package com.cmic.rcs.emoji.common.task;
//
//import com.cmic.rcs.emoji.common.CustomContext;
//import com.cmic.rcs.emoji.common.util.CommonUtils;
//import com.cmic.rcs.emoji.dao.EmojiMapper;
//import com.cmic.rcs.emoji.manager.EmojiManager;
//import com.cmic.rcs.emoji.model.entity.EmojiEntity;
//import lombok.extern.slf4j.Slf4j;
//import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//import java.util.List;
//
///**
// * @author hzr
// */
//@Slf4j
//@Component
//public class CheckTask {
//
//    @Value("${CheckRetryCount:5}")
//    private Integer retryCount;
//
//    @Autowired
//    private EmojiManager emojiManager;
//    @Autowired
//    private EmojiMapper emojiMapper;
//
//    @Scheduled(cron = "0 0 0/1 * * ?")
//    @SchedulerLock(name = "checkTask1")
//    public void scheduledTask1() {
//        String traceId = CommonUtils.getUuid();
//        CustomContext.setTraceId(traceId);
//        LocalDateTime start = LocalDateTime.now().minusDays(1);
//        LocalDateTime end = LocalDateTime.now().minusHours(2);
//        List<EmojiEntity> emojiEntities = emojiMapper.selectUnchecked(start, end, retryCount);
//        log.info("送审定时任务1: {}, {}, {}", start, end, emojiEntities);
//        for (EmojiEntity emojiEntity : emojiEntities) {
//            CustomContext.setTraceId(traceId + "-" + emojiEntity.getId());
//            emojiManager.asyncCheckEmoji(emojiEntity);
//        }
//        CustomContext.clear();
//    }
//
//    @Scheduled(cron = "0 0 0/5 * * ?")
//    @SchedulerLock(name = "checkTask2")
//    public void scheduledTask2() {
//        String traceId = CommonUtils.getUuid();
//        CustomContext.setTraceId(traceId);
//        LocalDateTime start = LocalDateTime.now().minusDays(5);
//        LocalDateTime end = LocalDateTime.now().minusDays(1);
//        List<EmojiEntity> emojiEntities = emojiMapper.selectUnchecked(start, end, retryCount);
//        log.info("送审定时任务2: {}, {}, {}", start, end, emojiEntities);
//        for (EmojiEntity emojiEntity : emojiEntities) {
//            CustomContext.setTraceId(traceId + "-" + emojiEntity.getId());
//            emojiManager.asyncCheckEmoji(emojiEntity);
//        }
//        CustomContext.clear();
//    }
//}
